const child_process = require('child_process');

const moment = require('moment');

const git = require('git-rev-sync');

const commitHash = 'dev'

const curBrach = git.branch();

const message = git.message();

const date = moment(git.date()).format('YYYY-MM-DD HH:mm:ss');

const proj = 'teacher-admin';

const curl = `curl -X POST --data "token=dev-nginx-static-token&TAG=${commitHash}&ENV=dev&PROJ=${proj}" https://admin:11dc8e39876ecf6be9228c97d1d0164a2d@alidev-jenkins.iqidao.com/job/dev-nginx-staticzp49n/job/dev-nginx-static/buildWithParameters`;

child_process.exec(curl, function (err, stdout, stderr) {
  console.log('-----打包信息------');
  console.log('\n');
  console.log(`项目名称:  ${proj}`);
  console.log('\n');
  console.log(`打包commit-hash:  ${commitHash}`);
  console.log('\n');
  console.log(`commit-message:  ${message}`);
  console.log('\n');
  console.log(`当前分支:  ${curBrach}`);
  console.log('\n');
  console.log(`代码上传时间:  ${date}`);
  console.log('\n');
  console.log(
    `查看打包进度:  https://ali-devops.iqidao.com/dev/clusters/host/devops/dev-nginx-staticzp49n/pipelines/dev-nginx-static/`,
  );
  console.log(`查看进度列表完整第一次加载比较慢，不需要刷新界面，等待30s+就可以看到进度`);
  console.log('---------------');
});
